package com.tian.arch.util

import android.content.Context
import android.content.res.Resources
import android.graphics.drawable.Drawable
import androidx.core.content.ContextCompat
import com.tian.arch.Foundation


/**
 * 提供的一系列扩展函数
 */
fun Int.toResDimen(context: Context? = null): Float = Foundation.context().resources.getDimension(this)
fun Int.toResColor(context: Context? = null): Int = ContextCompat.getColor((context ?: Foundation.context()), this)
fun Int.toResString(context: Context? = null, vararg args: Any?): String = (context ?: Foundation.context()).getString(this, *args)
fun Int.toResDrawable(context: Context? = null): Drawable? = ContextCompat.getDrawable((context ?: Foundation.context()), this)
fun Int.dp(): Float = (this * (Resources.getSystem().displayMetrics.density) + 0.5f)